package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.AskLeave;
import com.ruoyi.system.domain.Emplyee;
import com.ruoyi.system.mapper.EmplyeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.LeaveMapper;
import com.ruoyi.system.domain.Leave;
import com.ruoyi.system.service.ILeaveService;

/**
 * leaveService业务层处理
 *
 * @author ruoyi
 * @date 2023-10-11
 */
@Service
public class LeaveServiceImpl implements ILeaveService
{
    @Autowired
    private LeaveMapper leaveMapper;
    @Autowired
    private EmplyeeMapper EmplyeeMapper;

    /**
     * 查询leave
     *
     * @param id leave主键
     * @return leave
     */
    @Override
    public Leave selectLeaveById(Long id)
    {
        Leave leave = leaveMapper.selectLeaveById(id);
        return leave;
    }

    /**
     * 查询leave列表
     *
     * @param leave leave
     * @return leave
     */
    @Override
    public List<Leave> selectLeaveList(Leave leave)
    {
        return leaveMapper.selectLeaveList(leave);
    }

    /**
     * 新增leave
     *
     * @param leave leave
     * @return 结果
     */
    @Override
    public int insertLeave(Leave leave)
    {
        return leaveMapper.insertLeave(leave);
    }

    /**
     * 修改leave
     *
     * @param leave leave
     * @return 结果
     */
    @Override
    public int updateLeave(Leave leave)
    {
        return leaveMapper.updateLeave(leave);
    }

    /**
     * 批量删除leave
     *
     * @param ids 需要删除的leave主键
     * @return 结果
     */
    @Override
    public int deleteLeaveByIds(Long[] ids)
    {
        return leaveMapper.deleteLeaveByIds(ids);
    }

    /**
     * 删除leave信息
     *
     * @param id leave主键
     * @return 结果
     */
    @Override
    public int deleteLeaveById(Long id)
    {
        return leaveMapper.deleteLeaveById(id);
    }

    //查询所有待审批状态
    @Override
    public List<Leave> selectListByStatus(Long index) {
        Leave leave = new Leave();
        leave.setStatus(index.toString());
        leave.setType("0");
        return leaveMapper.selectLeaveList(leave);
    }
}
